package com.AC.ACGBit;

import java.util.Scanner;

public class test2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b=  sc.nextInt();
        int c = sc.nextInt();
        int n = sc.nextInt();
        int xa = sc.nextInt();
        int ya = sc.nextInt();
        int xb = sc.nextInt();
        int yb = sc.nextInt();
        int xc = sc.nextInt();
        int yc = sc.nextInt();
        getNum(a, b, c, new int[]{xa,ya}, new int[]{xb,yb}, new int[]{xc,yc},n);
    }


    public static void getNum(int a, int b, int c, int[] A, int[] B, int[] C, int n){
        int mod = 1000000007;
        for(int i = 0; i<n; i++){
            int new_a = b * B[0] + c * C[0];
            int new_b = a * A[0] + c * C[1];
            int new_c = a * A[1] + b * B[1];
            a += new_a;
            a %= mod;
            b += new_b;
            b %= mod;
            c += new_c;
            c %= mod;
        }
        System.out.println(a + " " + b + " " + c);

    }

}
